package com.nbjtjc.safe.api.cost;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.nbjtjc.safe.bean.Result;
import com.nbjtjc.safe.service.cost.FrontPageService;

@RestController
@CrossOrigin("*")
@RequestMapping("/costFrontPage")
public class FrontPageController {
	@Autowired
	private FrontPageService frontPageService;
	  @RequestMapping(value = "/eduCondition",method = {RequestMethod.POST})
	    public Result eduCondition(String year){
		  Result result = new Result();
			SimpleDateFormat sdf = new SimpleDateFormat("yyyy");
			Date yeard;
			try {
				yeard = sdf.parse(year);
				result.setData(frontPageService.eduCondition(yeard));

			} catch (ParseException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		  return result;
	  }
	  
	  @RequestMapping(value = "/costCondition",method = {RequestMethod.POST})
	    public Result costCondition(String year){
		  Result result = new Result();
			SimpleDateFormat sdf = new SimpleDateFormat("yyyy");
			Date yeard;
			try {
				yeard = sdf.parse(year);
				result.setData(frontPageService.costCondition(yeard));

			} catch (ParseException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		  return result;
	  }
}
